import { del, get, post, put } from '~/utils/request'

/**
 * 获取部门列表
 * @param count
 * @param limitNum
 * @returns 部门列表数据
 */
export function getDepartmentList(count: number, limitNum: number) {
  return get('/department/list', { count, limitNum })
}

/**
 * 创建部门
 * @param departmentData 部门数据
 * @param departmentData.parentId 父部门ID
 * @param departmentData.name 部门名称
 * @param departmentData.code 部门编号
 * @param departmentData.sort 排序号
 * @param departmentData.status 状态(1启用 0禁用)
 * @returns 创建结果
 */
export function createDepartment(departmentData: {
  parentId: string
  name: string
  code: string
  sort: number
  status: number
}) {
  return post('/department/create', departmentData)
}

/**
 * 更新部门
 * @param id 部门ID
 * @param departmentData 部门更新数据
 * @param departmentData.parentId 父部门ID
 * @param departmentData.name 部门名称
 * @param departmentData.code 部门编号
 * @param departmentData.sort 排序号
 * @param departmentData.status 状态(1启用 0禁用)
 * @returns 更新结果
 */
export function updateDepartment(
  id: string,
  departmentData: {
    parentId?: string
    name?: string
    code?: string
    sort?: number
    status?: number
  },
) {
  return put(`/department/update/${id}`, departmentData)
}

/**
 * 删除部门
 * @param id 部门ID
 * @returns 删除结果
 */
export function deleteDepartment(id: string) {
  return del(`/department/delete/${id}`)
}
